home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / UUPC3 / MAC_SPEC / UNIX_LIB / HFIXNAM.C < prev    next >
C/C++ Source or Header  |  1988-03-10  |  981b  |  66 lines

  1.  
  2. #ifdef TEST
  3. #include <stdio.h>
  4. #endif
  5. #include <pb.h>
  6.  
  7.  
  8. hfixnam( path, npath )
  9. char * path;
  10. char * npath;
  11. {
  12.  
  13.     HPrmBlkRec pb;
  14.     char vname[256];
  15.  
  16.     strcpy( vname, "" );
  17.     strcpy( npath, "" );
  18.     
  19.     pb.ioNamePtr = vname;
  20.  
  21. #ifdef TEST
  22.     fprintf( stderr, "hfixnam: before \"%s\"\n", path );
  23. #endif
  24.  
  25.     pb.ioVRefNum = fixnam( path, npath );
  26.  
  27. #ifdef TEST
  28.     fprintf( stderr, "hfixnam: vrefnum %d\n", pb.ioVRefNum );
  29.     fprintf( stderr, "hfixnam: after \"%s\"\n", npath );
  30. #endif
  31.  
  32.     pb.u.hvp.ioVolIndex = 0;
  33.  
  34.     if (PBGetVInfo(&pb, 0) == 0) {
  35.         ptoc( vname );
  36.  
  37. #ifdef TEST
  38.         fprintf( stderr, "hfixnam: \"%s\"\n", vname );
  39. #endif
  40.  
  41.         strcat( vname, npath );
  42.         strcpy( npath, vname );
  43.     }
  44.     
  45.     return pb.ioVRefNum;
  46.  
  47. }
  48.  
  49.  
  50. #ifdef TEST
  51. #include <errno.h>
  52.  
  53. main()
  54. {
  55.     char command[100];
  56.     char ncommand[100];
  57.     int vrefnum;
  58.  
  59.     while ( gets( command ) != NULL) {
  60.         fprintf( stderr, "test: %s \n", command );
  61.         vrefnum = hfixnam( command, ncommand );
  62.         fprintf( stderr, "test: %d %s\n", vrefnum, ncommand );
  63.     }
  64. }
  65. #endif
  66.